from hysdata import api, HSClient
from hysdata.store import Store
import asyncio

# store = Store(con_url="mysql+mysqlconnector://username:password@host:port/db", debug=True)
store = Store(debug=False)


@store.save(unique_cols=['HS代码'])
def stock_list(clt: HSClient):
    return clt.sync_query(api.stock_list(), cn_column_names=True)


@store.async_save(unique_cols=['HS代码'])
async def async_stock_list(clt: HSClient):
    return await clt.async_query(api.stock_list(), cn_column_names=True)


if __name__ == "__main__":
    client = HSClient()
    loop = asyncio.get_event_loop()
    df2 = loop.run_until_complete(async_stock_list(client))
    print(df2)
